summaryrefslogtreecommitdiff
path: root/tau/src/js/jqm
diff options
context:
space:
mode:
Diffstat (limited to 'tau/src/js/jqm')
-rw-r--r--tau/src/js/jqm/all.js2
-rw-r--r--tau/src/js/jqm/engine.js20
-rw-r--r--tau/src/js/jqm/router.js27
-rw-r--r--tau/src/js/jqm/widget.js226
4 files changed, 127 insertions, 148 deletions
diff --git a/tau/src/js/jqm/all.js b/tau/src/js/jqm/all.js
index 80ff68a6..da55f87b 100644
--- a/tau/src/js/jqm/all.js
+++ b/tau/src/js/jqm/all.js
@@ -1,5 +1,5 @@
/*global define */
-/*
+/*
* Copyright (c) 2010 - 2014 Samsung Electronics Co., Ltd.
* License : MIT License V2
*/
diff --git a/tau/src/js/jqm/engine.js b/tau/src/js/jqm/engine.js
index 3b212bd1..6c152f87 100644
--- a/tau/src/js/jqm/engine.js
+++ b/tau/src/js/jqm/engine.js
@@ -1,6 +1,6 @@
/*global window, define, console */
/*jslint plusplus: true, nomen: true */
-/*
+/*
* Copyright (c) 2010 - 2014 Samsung Electronics Co., Ltd.
* License : MIT License V2
*/
@@ -21,8 +21,7 @@
"../core/util/object",
"../core/event",
"../core/util/zoom",
- "../core/util/load",
- "../core/frameworkData"
+ "../core/util/load"
],
function () {
//>>excludeEnd("tauBuildExclude");
@@ -115,9 +114,9 @@
nsNormalizeDict[prop] = nsNormalizeDict[prop] || $.camelCase($.mobile.ns + prop);
return nsNormalizeDict[prop];
},
- activeBtnClass : ns.widget.core.Button.classes.uiBtnActive,
+ activeBtnClass : ns.widget.mobile.Button.classes.uiBtnActive,
activePageClass : ns.widget.mobile.Page.classes.uiPageActive,
- focusClass : ns.widget.core.Button.classes.uiFocus,
+ focusClass : ns.widget.mobile.Button.classes.uiFocus,
version: "1.2.0",
getAttrFixed: function (element, key) {
var value = element.getAttribute(key);
@@ -382,18 +381,17 @@
*/
document.addEventListener(ns.engine.eventType.WIDGET_BOUND, function (event) {
var originalEvent = event.originalEvent || event,
- widget = originalEvent.detail,
- widgetName = widget && widget.widgetName;
- widgetName = widgetName && widgetName.toLowerCase();
- if (widgetName && widget.element) {
+ widget = originalEvent.detail;
+ if (widget && widget.element && widget.widgetName) {
try {
//>>excludeStart("tauDebug", pragmas.tauDebug);
- ns.log("Running jqm constructor for " + widgetName);
+ ns.log("Running jqm constructor for " + widget.wigdetName);
//>>excludeEnd("tauDebug");
+ $(widget.element)[widget.widgetName]();
} catch(e) {
// suppress errors in not debug mode
//>>excludeStart("tauDebug", pragmas.tauDebug);
- ns.warning("could not call jqm constructor for " + widgetName, widget, e);
+ ns.warning("could not call jqm constructor for " + widget.widgetName, widget, e);
//>>excludeEnd("tauDebug");
}
diff --git a/tau/src/js/jqm/router.js b/tau/src/js/jqm/router.js
index 250f80d3..26d31733 100644
--- a/tau/src/js/jqm/router.js
+++ b/tau/src/js/jqm/router.js
@@ -1,6 +1,6 @@
/*global window, define, HTMLElement */
/*jslint plusplus: true, nomen: true */
-/*
+/*
* Copyright (c) 2010 - 2014 Samsung Electronics Co., Ltd.
* License : MIT License V2
*/
@@ -16,6 +16,7 @@
[
"../core/engine",
"../core/util/path",
+ "../profile/mobile/router/urlHistory",
"./namespace"
],
function () {
@@ -41,8 +42,9 @@
if (!container instanceof HTMLElement) {
container = document.body;
}
- ns.setConfig('pageContainer', container);
+ ns.setConfig('container', container);
$.mobile.pageContainer = $(container);
+ router.setContainer(container);
}
if ($.mobile.autoInitializePage !== undefined) {
ns.setConfig('autoInitializePage', $.mobile.autoInitializePage);
@@ -58,15 +60,11 @@
}
return router.open(toPage, options);
};
- document.addEventListener('pagechange', function () {
- var route = router.getRoute("page"),
- activePage = route && route.getActive(),
- target = activePage && activePage.element;
- $.mobile.activePage = $(target);
+ document.addEventListener('pageshow', function (ev) {
+ $.mobile.activePage = $(ev.target);
}, true);
- $.mobile.activePage = $();
$.mobile.firstPage = $(router.getFirstPage());
- $.mobile.pageContainer = $();
+ $.mobile.pageContainer = $(router.getContainer());
$.mobile.subPageUrlKey = ns.widget.mobile.Page.classes.uiPage;
$.mobile.ajaxEnabled = true;
$.mobile.hashListeningEnabled = true;
@@ -88,7 +86,7 @@
$.mobile.transitionFallbacks = {};
$.mobile._maybeDegradeTransition = null;
$.mobile.focusPage = null;
- //$.mobile.urlHistory = ns.router.urlHistory;
+ $.mobile.urlHistory = ns.router.urlHistory;
$.mobile.dialogHashKey = "&ui-state=dialog";
$.mobile.allowCrossDomainPages = false;
$.mobile.getDocumentUrl = ns.util.path.getDocumentUrl;
@@ -112,8 +110,7 @@
var transitions,
name,
container,
- router = engine.getRouter(),
- containerWidget;
+ router = engine.getRouter();
if ($) {
$.mobile.defaultPageTransition = "none";
@@ -140,12 +137,10 @@
pageWidget.focus();
};
+ $.mobile._bindPageRemove = $.mobile._bindPageRemove || router._bindPageRemove.bind(router);
$.mobile.initializePage = router.init.bind(router);
container = router.getContainer();
- containerWidget = router.getContainer();
- if (containerWidget) {
- $.mobile.pageContainer = $(containerWidget.element);
- }
+ $.mobile.pageContainer = $(container);
}
}
};
diff --git a/tau/src/js/jqm/widget.js b/tau/src/js/jqm/widget.js
index fd7cdb97..4b1dd496 100644
--- a/tau/src/js/jqm/widget.js
+++ b/tau/src/js/jqm/widget.js
@@ -1,6 +1,6 @@
/*global window, define */
/*jslint plusplus: true, nomen: true */
-/*
+/*
* Copyright (c) 2010 - 2014 Samsung Electronics Co., Ltd.
* License : MIT License V2
*/
@@ -99,132 +99,118 @@
*/
methods = definition.methods;
- $.fn[name] = widgetConstructor(engine, name, methods, definition.name);
- if (definition.namespace) {
- $[definition.namespace] = $[definition.namespace] || {};
- $[definition.namespace][definition.name.toLowerCase()] = definition.widgetClass;
- }
- definition = null;
- }
- };
-
-
- function widgetConstructor(engine, name, methods, instanceWidgetName) {
- /*
- * widget instance
- * type Object
- */
- var instance = null;
- return function () {
- /*
- * function arguments
- * type Array
- */
- var args = slice.call(arguments),
- /*
- * element of jQuery collection
- * type HTMLElement
- */
- element,
- /*
- * is built?
- * type Boolean
- */
- built,
- /*
- * name of method
- * type string
- */
- method,
- /*
- * result value
- * type mixed
- */
- resultValue,
- /*
- * first argument of function
- * type mixed
- */
- firstarg,
- i,
- options = {},
- argsLength,
- argument;
+ $.fn[name] = (function ($, engine, name, bindingNamespace, methods) {
+ /*
+ * widget instance
+ * type Object
+ */
+ var instance = null;
+ return function () {
+ /*
+ * function arguments
+ * type Array
+ */
+ var args = slice.call(arguments),
+ /*
+ * element of jQuery collection
+ * type HTMLElement
+ */
+ element,
+ /*
+ * is built?
+ * type Boolean
+ */
+ built,
+ /*
+ * name of method
+ * type string
+ */
+ method,
+ /*
+ * result value
+ * type mixed
+ */
+ resultValue,
+ /*
+ * first argument of function
+ * type mixed
+ */
+ firstarg,
+ i,
+ options = {},
+ instanceWidgetName = definition.name;
- /*
- * NOTE:
- * The loop below contains some fixes/hacks for TizenSlider, Listview with FastScroll and AutoDividers
- * and also Popup, please be aware while refactoring.
- */
- for (i = 0; i < this.length; i++) {
- element = this.get(i);
- switch(name){
- case "slider":
- instance = engine.getBinding(element, "Slider") || engine.getBinding(element, "TizenSlider");
- break;
- default:
- instance = engine.getBinding(element, instanceWidgetName);
- }
+ /*
+ * NOTE:
+ * The loop below contains some fixes/hacks for TizenSlider, Listview with FastScroll and AutoDividers
+ * and also Popup, please be aware while refactoring.
+ */
+ for (i = 0; i < this.length; i++) {
+ element = this.get(i);
+ switch(name){
+ // FastScroll has not real instance defined because it's build as an extension
+ case "fastscroll":
+ instance = engine.getBinding(element, "Listview");
+ break;
+ case "slider":
+ instance = engine.getBinding(element, "Slider") || engine.getBinding(element, "TizenSlider");
+ break;
+ default:
+ instance = engine.getBinding(element, instanceWidgetName);
+ }
- built = instance && instance.isBuilt();
- firstarg = args.shift();
- if (firstarg === undefined || typeof firstarg === 'object') {
- if (typeof firstarg === 'object') {
- options = firstarg;
- }
- if (!instance || !built) {
- engine.instanceWidget(element, instanceWidgetName, options);
- } else {
- instance.configure(null, element, options);
- }
- } else {
- if (instance === null) {
- return this;
- }
- method = firstarg;
- if (method === "destroy") {
- instance.destroy();
- return this;
- }
- if (methods.indexOf(method) < 0) {
- throw "Method " + method + " does not exist!";
- }
- if (name === 'listview' &&
- method === 'option' &&
- args[0] === "autodividersSelector" &&
- typeof args[1] === 'function') {
- // wrap first argument of callback method in JQuery object
- args[1] = wrapFn(args[1]);
- }
- if (name === "popup" && method === "open") {
- // window.event is used because in Winset we open context popup by
- // $("#pop_text_only").popup("open") after clicking on input
- args[1] = window.event;
- }
- // transform jQuery arguments to HTMLElement
- argsLength = args.length;
- for (i = 0; i < argsLength; i++) {
- argument = args[i];
- if (argument instanceof jQuery) {
- // convert jQuery object to array of HTMLElement
- argument = argument.makeArray();
- // if we have only one element we take only first element
- if (argument.length === 1) {
- argument = argument[0];
+ built = instance && instance.isBuilt();
+ firstarg = args.shift();
+ if (firstarg === undefined || typeof firstarg === 'object') {
+ if (typeof firstarg === 'object') {
+ options = firstarg;
+ }
+ if (!instance || !built) {
+ engine.instanceWidget(element, definition.name, options);
+ } else {
+ instance.configure(null, element, options);
+ }
+ } else {
+ if (instance === null) {
+ return this;
+ }
+ method = firstarg;
+ if (method === "destroy") {
+ instance.destroy();
+ return this;
+ }
+ if (methods.indexOf(method) < 0) {
+ throw "Method " + method + " does not exist!";
+ }
+ if (name === 'listview' &&
+ method === 'option' &&
+ args[0] === "autodividersSelector" &&
+ typeof args[1] === 'function') {
+ // wrap first argument of callback method in JQuery object
+ args[1] = wrapFn(args[1]);
+ }
+ if (name === "popup" && method === "open") {
+ // window.event is used because in Winset we open context popup by
+ // $("#pop_text_only").popup("open") after clicking on input
+ args[1] = window.event;
+ }
+ resultValue = instance[method].apply(instance, args);
+ if (resultValue !== undefined) {
+ if (resultValue !== instance) {
+ return resultValue;
+ }
+ }
}
}
- }
- resultValue = instance[method].apply(instance, args);
- if (resultValue !== undefined) {
- if (resultValue !== instance) {
- return resultValue;
- }
- }
+ return this;
+ };
+ }($, engine, name, definition.binding, methods));
+ if (definition.namespace) {
+ $[definition.namespace] = $[definition.namespace] || {};
+ $[definition.namespace][definition.name.toLowerCase()] = definition.widgetClass;
}
}
- return this;
};
- }
document.addEventListener(engine.eventType.WIDGET_DEFINED, function (evt) {
jqmWidget.init(engine, evt.detail);