1 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
2 //>>description: Tizen core library
6 define( [ 'jquery.mobile.core', 'jquery.mobile.tizen.configure', 'util/ensurens' ], function ( ) {
7 //>>excludeEnd("jqmBuildExclude");
10 * jQuery Mobile Widget @VERSION
12 * TODO: remove unnecessary codes....
14 * This software is licensed under the MIT licence (as defined by the OSI at
15 * http://www.opensource.org/licenses/mit-license.php)
17 * ***************************************************************************
18 * Copyright (C) 2011 by Intel Corporation Ltd.
20 * Permission is hereby granted, free of charge, to any person obtaining a
21 * copy of this software and associated documentation files (the "Software"),
22 * to deal in the Software without restriction, including without limitation
23 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
24 * and/or sell copies of the Software, and to permit persons to whom the
25 * Software is furnished to do so, subject to the following conditions:
27 * The above copyright notice and this permission notice shall be included in
28 * all copies or substantial portions of the Software.
30 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
35 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
36 * DEALINGS IN THE SOFTWARE.
37 * ***************************************************************************
39 * Authors: Kalyan Kondapally <kalyan.kondapally@intel.com>
42 ensureNS("jQuery.mobile.tizen");
45 jQuery.extend(jQuery.mobile.tizen, {
46 disableSelection: function (element) {
48 $(element).find('*').not( 'input, [type="text"], textarea' ),
54 enableSelection: function (element, value) {
66 return $(element).css( {
68 '-moz-user-select': val,
69 '-webkit-user-select': val,
70 '-o-user-select': val,
75 disableContextMenu: function(element) {
77 $(element).find('*').each( function() {
78 if( ( $(this).get(0).tagName !== 'INPUT' &&
79 $(this).attr("type") !== 'text' ) &&
80 $(this).get(0).tagName !== 'TEXTAREA' ) {
81 self._disableContextMenu( this );
86 _disableContextMenu: function(element) {
88 $(element).each( function() {
89 $(this).bind("contextmenu", function( event ) {
95 enableContextMenu: function(element) {
96 $(element).each( function() {
97 $(this).unbind( "contextmenu" );
101 // Get document-relative mouse coordinates from a given event
102 // From: http://www.quirksmode.org/js/events_properties.html#position
103 documentRelativeCoordsFromEvent: function(ev) {
104 var e = ev ? ev : window.event,
105 client = { x: e.clientX, y: e.clientY },
106 page = { x: e.pageX, y: e.pageY },
110 // Grab useful coordinates from touch events
111 if (e.type.match(/^touch/)) {
113 x: e.originalEvent.targetTouches[0].pageX,
114 y: e.originalEvent.targetTouches[0].pageY
117 x: e.originalEvent.targetTouches[0].clientX,
118 y: e.originalEvent.targetTouches[0].clientY
122 if (page.x || page.y) {
127 if (client.x || client.y) {
128 posx = client.x + document.body.scrollLeft + document.documentElement.scrollLeft;
129 posy = client.y + document.body.scrollTop + document.documentElement.scrollTop;
132 return { x: posx, y: posy };
135 // TODO : offsetX, offsetY. touch events don't have offsetX and offsetY. support for touch devices.
136 // check algorithm...
137 targetRelativeCoordsFromEvent: function(e) {
138 var coords = { x: e.offsetX, y: e.offsetY };
140 if (coords.x === undefined || isNaN(coords.x) ||
141 coords.y === undefined || isNaN(coords.y)) {
142 var offset = $(e.target).offset();
143 //coords = documentRelativeCoordsFromEvent(e); // Old code. Must be checked again.
144 coords = $.mobile.tizen.documentRelativeCoordsFromEvent(e);
145 coords.x -= offset.left;
146 coords.y -= offset.top;
155 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
157 //>>excludeEnd("jqmBuildExclude");