Large diffs are not rendered by default.

@@ -0,0 +1,216 @@
(function(factory) {
if (typeof define === 'function' && define.amd) {
// AMD
define(['jquery'], factory);
} else if (typeof module === 'object' && module.exports) {
factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function ($, window, document, undefined) {

"use strict";

var pluginName = "ccPicker";
var defaults = {
countryCode: "IR",
dialCodeFieldName: "phoneCode",
dataUrl: "../Statics/javascripts/countries.json",
countryFilter: true,
searchPlaceHolder: "Search"
};


function CcPicker(element, options) {
var self = this;
this.element = element;
this.options = $.extend({}, defaults, options);
this._defaults = defaults;
this._name = pluginName;
this._list = {};
this._filter = {};
this._ccData = {};
this._ccPicker = {};
this._ccDialCodeTrackerField = {};
this._ccSelectedCountry = {};
this.init();

function setCountryByPhoneCode(code) {
var cc = self.findCountryByPhoneCode(self, code);
self._ccPicker.html(self.createCountryListItem(cc.code, cc.phoneCode));
self._ccDialCodeTrackerField.val(cc.phoneCode);
self._ccSelectedCountry = {code: cc.code, phoneCode: cc.phoneCode};
$(self.element).trigger("countrySelect", cc);
}

function setCountryByCode(code) {
var cc = self.findCountryByCountryCode(self, code);
self._ccPicker.html(self.createCountryListItem(cc.code, cc.phoneCode));
self._ccDialCodeTrackerField.val(cc.phoneCode);
self._ccSelectedCountry = {code: cc.code, phoneCode: cc.phoneCode};
$(self.element).trigger("countrySelect", cc);
}

function disable() {
$(self.element).prop('disabled', true);
self._ccPicker.off("click");
self._ccPicker.css("cursor", "default");
}

function enable() {
$(self.element).prop('disabled', false);
self._ccPicker.off("click");
self._ccPicker.on("click", function (e) {
$.isEmptyObject(self._list) ? self.createCountryList(self) : self.destroyCountryList(self);
e.stopPropagation();
});
self._ccPicker.css("cursor", "pointer");
}

return {
setCountryByPhoneCode: setCountryByPhoneCode,
setCountryByCode: setCountryByCode,
disable: disable,
enable: enable
};
}

$.extend(CcPicker.prototype, {
init: function () {
var c = this;
this.loadCountryData(c);
var cc = this.findCountryByCountryCode(c, this.options.countryCode);
this._ccPicker = $('<div class="cc-picker cc-picker-code-select-enabled">').insertBefore(this.element);
this._ccDialCodeTrackerField = $('<input>').attr({
type: 'hidden',
id: this.element.id + "_" + this.options.dialCodeFieldName,
name: this.element.name + "_" + this.options.dialCodeFieldName,
value: cc.phoneCode
}).insertAfter(this.element);
this._ccPicker.prepend(this.createCountryListItem(this.options.countryCode.toLowerCase(), cc.phoneCode));
this._ccSelectedCountry = {code: this.options.countryCode.toLowerCase(), phoneCode: cc.phoneCode};
this._ccPicker.on("click", function (e) {
$.isEmptyObject(c._list) ? c.createCountryList(c) : c.destroyCountryList(c);
e.stopPropagation();
});
$("body").on("click", function () {
if (!$.isEmptyObject(c._list)) {
c.destroyCountryList(c);
}
});
},
loadCountryData: function (e) {
$.ajax({
dataType: 'json',
url: e.options.dataUrl,
type: 'get',
async: false,
success: function (data) {
e._ccData = data;
}
});

},
findCountryByPhoneCode: function (e, code) {
return $.grep(e._ccData, function (o) {
return o.phoneCode.toUpperCase() === code.toUpperCase();
})[0];
},
findCountryByCountryCode: function (e, code) {
return $.grep(e._ccData, function (o) {
return o.code.toUpperCase() === code.toUpperCase();
})[0];
},
createCountryList: function (e) {
var zIndex = e._ccPicker.css("z-index") === "auto" ? 0 : Number(e._ccPicker.css("z-index")) + 10;
e._list = $("<ul/>", {"class": "cc-picker-code-list"}).appendTo("body");
e._list.css({
top: e._ccPicker.offset().top + e._ccPicker.outerHeight() + (e.options.countryFilter === true ? 25 : 0),
left: e._ccPicker.offset().left,
"z-index": zIndex
});
$.each(e._ccData, function (key, val) {
var l = $("<li>", {text: val.countryName}).appendTo(e._list);
$(l).data("countryItem", val);
$(l).prepend(e.createCountryListItem(val.code, val.phoneCode));
$(l).on("click", function () {
e.selectCountry(e, $(this));
e.destroyCountryList(e);
});
if(val.phoneCode === e._ccSelectedCountry.phoneCode){
$(l).addClass("cc-picker-selected-country");
}
});

if (e.options.countryFilter) {
e._filter = $("<input/>", {"class": "cc-picker-code-filter", "placeholder": e.options.searchPlaceHolder}).insertBefore(e._list);
e._filter.css({
top: e._ccPicker.offset().top + e._ccPicker.outerHeight(),
left: e._ccPicker.offset().left,
"z-index": zIndex
});
e._filter.on("click", function (e) {
e.stopPropagation();
});
e._filter.on("keyup", function (e) {
var text = $(this).val();
$('.cc-picker-code-list li:not(:ccContains("' + text + '"))').hide();
$('.cc-picker-code-list li:ccContains("' + text + '")').show();
});
}
},
destroyCountryList: function (e) {
e._list.remove();
e._list = {};

if (e.options.countryFilter) {
e._filter.remove();
e._filter = {};
}
},
selectCountry: function (e, c) {
var i = $(c).data("countryItem");
this._ccSelectedCountry = i;
e._ccPicker.html(e.createCountryListItem(i.code, i.phoneCode));
e._ccDialCodeTrackerField.val(i.phoneCode, i.code, i.phoneCode);
$(e.element).trigger("countrySelect", i);
},
createCountryListItem: function (countryCode, dialCode) {
return '<div class="cc-picker-flag ' + countryCode.toLowerCase() + '"></div><span class="cc-picker-code">' + dialCode + '</span> ';
}
});

$.extend($.expr[":"], {
ccContains: function (a, i, m) {
return $(a).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0;
}
});

$.fn.CcPicker = function (options) {
if (typeof arguments[0] === 'string') {
var methodName = arguments[0];
var args = Array.prototype.slice.call(arguments, 1);
var returnVal;
this.each(function () {
if ($.data(this, 'plugin_' + pluginName) && typeof $.data(this, 'plugin_' + pluginName)[methodName] === 'function') {
returnVal = $.data(this, 'plugin_' + pluginName)[methodName].apply(this, args);
} else {
throw new Error('Method ' + methodName + ' does not exist on jQuery.' + pluginName);
}
});
if (returnVal !== undefined) {
return returnVal;
} else {
return this;
}
} else if (typeof options === "object" || !options) {
return this.each(function () {
if (!$.data(this, 'plugin_' + pluginName)) {
$.data(this, 'plugin_' + pluginName, new CcPicker(this, options));
}
});
}
};

}));
@@ -11,7 +11,7 @@ body {
width:100%;
height: 100%;
}
a,h1,h2,h3,h4,h5,h6,p,span,input,button,textarea{
a,h1,h2,h3,h4,h5,h6,p,span,input,button,textarea,form,ul,li,div,label{
text-decoration: none;
font-family: "Century Schoolbook L", sans-serif;
color: white;
@@ -34,7 +34,7 @@ a,h1,h2,h3,h4,h5,h6,p,span,input,button,textarea{
height: auto;
display: block;
float: left;
background-color: palevioletred;
background-color: whitesmoke;

}

@@ -56,6 +56,7 @@ a,h1,h2,h3,h4,h5,h6,p,span,input,button,textarea{
top:50px;
text-align: center;
}

.containerDiv > div h2,.containerDiv > div input,.containerDiv > div button{
position: relative;
clear: right;
@@ -79,7 +80,6 @@ a,h1,h2,h3,h4,h5,h6,p,span,input,button,textarea{
text-align: center;
}
.containerDiv > div form div{
left:0;
width:80%;
color:black;
background-color: transparent;
@@ -90,13 +90,6 @@ a,h1,h2,h3,h4,h5,h6,p,span,input,button,textarea{
.containerDiv > div form div input{
background-color: white;
position: relative;
float: left;
left:10%;
width:80%;
height: 40px;
color:black;
font-size:24px;
line-height: 35px;
top:10px;
text-align: center;
-webkit-transition: all 0.3s ease-in;
@@ -105,11 +98,63 @@ a,h1,h2,h3,h4,h5,h6,p,span,input,button,textarea{
-o-transition: all 0.3s ease-in;
transition: all 0.3s ease-in;
}
.containerDiv > div form div input:focus{
outline: #ff0055;
.containerDiv > div form .form-group{
float: left;
width: auto;
height: 80px;
color: white;
font-size: 24px;
line-height: 35px;
width: 300px;
margin: 30px 20px;
display: inline-grid;

}
.containerDiv > div form .form-group input{
background: none;
border:none;
width: 100%;
height: 100%;
padding:15px 8px 15px;
border-bottom:2px solid #aaa;
color:transparent;
font-size:16px;
outline: none;
-webkit-appearance: none;
-moz-appearance: none;
color:white;
}
.containerDiv > div form .form-group label{
position: absolute;
bottom:14px;
font-size:16px;
opacity: .5;
height: 20px;
color:#aaa;
width: 100%;
cursor: text;
-webkit-transition: all 0.3s ease-in;
-moz-transition: all 0.3s ease-in;
-ms-transition: all 0.3s ease-in;
-o-transition: all 0.3s ease-in;
transition: all 0.3s ease-in;
}
.containerDiv > div form .form-group input:focus ,.containerDiv > div form .form-group input.blurred{
color:white;
border-color:#ff0055;
}
.containerDiv > div form .form-group input:focus{
-webkit-transition: all 0.3s ease-in;
-moz-transition: all 0.3s ease-in;
-ms-transition: all 0.3s ease-in;
-o-transition: all 0.3s ease-in;
transition: all 0.3s ease-in;
}
.containerDiv > div form div input.changed{
text-align: left;
.containerDiv > div form .form-group input:focus + label ,.containerDiv > div form .form-group input.blurred + label{
font-size:12px;
bottom:-12px;
opacity: 0.5;
color:#ff0055;
}
.containerDiv > div form div img{
background-color: white;

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.